package com.lanxiao.cloud.modules.user.domain.model;

import com.baomidou.mybatisplus.annotation.TableName;
import com.lanxiao.cloud.common.core.enums.SexEnum;
import com.lanxiao.cloud.common.core.enums.StateEnum;
import com.lanxiao.cloud.common.core.error.LoginErrorType;
import com.lanxiao.cloud.common.core.exception.BusinessException;
import com.lanxiao.cloud.common.core.utils.StringUtils;
import com.lanxiao.cloud.common.mybatis.basic.Entity;
import java.util.Date;

/**
 * @author ：qiaoliang
 * @date ：2021-09-13
 */
@TableName(value = "sys_user", autoResultMap = true)
public class User extends Entity<Long> {
  /** 昵称 **/
  private String name;
  /** 首字符 **/
  private String initials;
  /** 头像 **/
  private String portrait;
  /** 性别 **/
  private SexEnum sex;
  /** 手机号 **/
  private String phone;
  /** 签名 **/
  private String autograph;
  /** 所属部门 **/
  private Long deptId;
  /** 状态 **/
  private StateEnum state;
  /** 注册IP **/
  private String createIp;
  /** 登录时间 **/
  private Date loginTime;
  /** 登录IP **/
  private String loginIp;

  public void checkLogin() {
    BusinessException.isTrue(StateEnum.ERROR.equals(this.getState()),
        LoginErrorType.ACCOUNT_IS_STATUS_ERROR);
  }

  public User() {
  }

  public User(Long id, Long deptId) {
    super(id);
    this.deptId = deptId;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getInitials() {
    return initials;
  }

  public void setInitials(String initials) {
    this.initials = initials;
  }

  public String getPortrait() {
    return portrait;
  }

  public void setPortrait(String portrait) {
    this.portrait = portrait;
  }

  public SexEnum getSex() {
    return sex;
  }

  public void setSex(SexEnum sex) {
    this.sex = sex;
  }

  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getAutograph() {
    return autograph;
  }

  public void setAutograph(String autograph) {
    this.autograph = autograph;
  }

  public Long getDeptId() {
    return deptId;
  }

  public void setDeptId(Long deptId) {
    this.deptId = deptId;
  }

  public StateEnum getState() {
    return state;
  }

  public void setState(StateEnum state) {
    this.state = state;
  }

  public String getCreateIp() {
    return createIp;
  }

  public void setCreateIp(String createIp) {
    this.createIp = createIp;
  }

  public Date getLoginTime() {
    return loginTime;
  }

  public void setLoginTime(Date loginTime) {
    this.loginTime = loginTime;
  }

  public String getLoginIp() {
    return loginIp;
  }

  public void setLoginIp(String loginIp) {
    this.loginIp = loginIp;
  }
}
